package cn.kai.ums.handle;


import cn.kai.ums.tools.JsonData;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 异常处理类
 */
@RestControllerAdvice
public class CustomHandler {

    @ExceptionHandler(value = Exception.class)
    public JsonData customHandler(Exception e){
        if(e instanceof SGMException){
           SGMException xdException = (SGMException) e;
            return JsonData.buildError(-1,"后端错误");
        }else {
            return JsonData.buildError(-2,e.getMessage());
        }
    }
}
